$(document).ready(function(){
		var $rongMH = $(window).width();
//		var $caoMH = $(window).height();
		var $rong = $(window).width()*70/100;
		var $cao = $(window).width()/25;
		var $vitri = $(window).width()*15/100;
//		var $si = $(window).width()/$(window).height()*6.2;
		var $caoImg = $(window).width()/9;
		/* Background */
		$('.backg').css({'width': $rong + 'px'});
		
		/* Menu */
		$('.menuMove').css({'width': $rong + 'px','height': $cao + 'px', 'margin-left': $vitri + 'px'});
		$('.menu IMG').css({'width': $cao + 100 + 'px'});
		$('.menu').css({'height': $cao + 'px', 'margin-left': -$vitri + 'px', 'width': $rongMH + 'px'});
		$('.drop').css({'height': $cao + 'px', 'line-height': $cao + 'px', 'width': '80%'});
		$('.label IMG').css({'height': $cao + 'px', 'width': '14%'});
		$('.dropItem div').css({'top': $cao + 'px'});
		$('.dropRight div').css({'top': $cao + 'px'});
		$('.imgTitle').css({'height': $caoImg + 'px', 'padding-top': $cao + 'px'});
		$('.imgTitle IMG').css({'height': $caoImg + 'px', 'width': $rongMH + 'px',
			'left': -$vitri + 'px'});
		/* Slide Show */
		$('.slideShow').css({'height': $caoImg*3.3 + 'px', 'top': -$caoImg/3 + 'px'});
		
		/* Content of main */
		$('.focus').css({'margin-bottom': $caoImg/3 + 'px'});
		
		/*Phan trang trong Man hinh*/
		/*var soluong = $('.rowPic').find('.frame').length;
	  	$('.sohinh').text(soluong);
  		$(".vidu").click(function(){
  		    $("#13").remove();
	  		$("#12").remove();
	  		$("#14").remove();
	  		var countPicRow = parseInt(($('.rowPic').find('.frame').length + 2)/3);
			var heightRow = countPicRow  * ($caoImg*3 + 20) + 20;
			$('.rowPic').height(heightRow);
			$('.soluong').text(countPicRow);
  		});
  			
  		$(".vidu2").click(function(){
	  		  $("#13").show();
	  		});*/
		
		
		/* Row Picture */
		$('.rowPic').css({'width': '100%', 'height': $caoImg*3 + 'px','margin-bottom': $caoImg/7 + 'px'});
		$('.frame').css({'margin-right': $vitri/20 + 'px', 'margin-left': $vitri/20 + 'px',
			'width': '31.1%', 'height':$caoImg*3 + 'px', 'margin-top':'20px'});
		var countPicRow = parseInt(($('.rowPic').find('.frame').length + 2)/3);
		var heightRow = countPicRow  * ($caoImg*3 + 20) + 20;
		$('.rowPic').height(heightRow);
		$('.soluong').text(countPicRow);
		
		$('.rate').css({'position': 'absolute', 'bottom': '5%', 'margin-left':'5%'});
		$('.thumbIMG').css({'height': '80%', 'width': '100%'});
		$('.under').css({'height': '20%', 'top': '80%', 'font-size': $caoImg/8 + 'px'});
		$('.infor').css({'margin': '5%', 'margin-top':'3%'});
		$('.under IMG').css({'height': '24px', 'width': '24px', 'position': 'absolute',
			'right':'2%', 'bottom':'5%'});
			
		/* footer */
		$('.footer').css({'left': -$vitri + 'px', 'width': $rongMH + 'px'});
		$('.intro').css({'background':'#393932', 'padding-bottom': '20px', 'border-bottom': '1px solid #535353'});
		
		$('.gioithieu').css({'margin-left': $vitri + 'px','width': '15%', 'color':'white'});
		$('.gioithieu .h').css({'padding': '20px 0px', 'padding-right': '20px'});
		$('.gioithieu div').css({'padding-right': '20px'});
		$('.gioithieu .h a').css({'color': 'white','font-family': 'Arial','border-bottom': '1px solid white',
			'font-weight': 'bold'});
	
			
		var $rong1 = $('.gioithieu').width() + $vitri;
		$('.giupdo').css({'position':'absolute','top':'0px','left': $rong1 + 'px','width': '15%', 'color':'white'});
		$('.giupdo .h').css({'padding': '20px 0px', 'padding-right': '20px'});
		$('.giupdo div').css({'padding-right': '20px'});
		$('.giupdo .h a').css({'color': 'white','font-family': 'Arial','border-bottom': '1px solid white',
			'font-weight': 'bold'});
		
		
		var $rong2 = $rong1 + $('.giupdo').width();
		$('.hoptac').css({'position':'absolute','top':'0px','left': $rong2 + 'px','width': '15%','color':'white'});
		$('.hoptac .h').css({'padding': '20px 0px', 'padding-right': '20px'});
		$('.hoptac div').css({'padding-right': '20px'});
		$('.hoptac .h a').css({'color': 'white','font-family': 'Arial','border-bottom': '1px solid white',
			'font-weight': 'bold'});
		
		var $rong3 = $rong2 + $('.hoptac').width();
		$('.khachhang').css({'position':'absolute','top':'0px','left': $rong3 + 'px','width': '25%', 'color':'white'});
		$('.khachhang .h').css({'padding': '20px 0px', 'padding-right': '20px'});
		$('.khachhang div').css({'padding-right': '20px'});
		$('.khachhang .h a').css({'color': 'white','font-family': 'Arial','border-bottom': '1px solid white',
			'font-weight': 'bold'});
		/* Link */
		$('.link').css({'height': $caoImg/1.5 + 'px'});
		var $caoSo = $('.link').height();
		$('.link .phone').css({'margin-left': $vitri + 'px', 'line-height': $caoSo + 'px', 'color': 'white', 'font-size': '30px'
		 ,'font-family': 'Arial'});
		$('.link div').css({'margin-left': $vitri + 'px'});
		var $rongphone = $('.link .phone').width();
		$('.social').css({'position': 'absolute', 'top': ($caoSo - 44)/2 + 'px', 'margin-left': $rongphone + $vitri + 50 + 'px'});
		
		/* Address */
		$('.addCon').css({'margin-left': $vitri + 'px'});
		
		/*Tao nut len dau trang*/
		$('#go_top').css({'width':'60px', 'height':'60px', 'position':'fixed', 'bottom':'30px', 'right':'10px',
			'background':'black', 'opacity':'0.6','background-image':'url("sources/icon/muiten.png")'});
});

$(document).ready(function() {
 
    var div = $('.menu');
    var start = $(div).offset().top;
 
    $.event.add(window, "scroll", function() {
        var p = $(window).scrollTop();
        $(div).css('position',((p)>start) ? 'fixed' : 'absolute');
        $(div).css('top',((p)>start) ? '0px' : '');
    });
 
});

/* Slide show */
function slideImage(){
	var $active = $('.slideShow IMG.active');
	if($active.length == 0){
		$active = $('.slideShow IMG:last');
	}
	
	var $next;
	if($active.next().length == false){
		$next = $('.slideShow IMG:first');
	}else{
		$next = $active.next();
	}
	
	$active.addClass('last-active');
	
	$next.css({opacity: 0.0}).addClass('active')
		.animate({opacity: 1.0}, 2000, function(){
			$active.removeClass('active last-active');
		});
	
}

$(function(){
	setInterval('slideImage()', 3000);
});


/*
 * Tao nut len dau trang
 * Ham: scrollTop
 * 
 * */
$(function(){
	//Ham ScrollTop
	$.fn.scrollToTop=function(){
		$(this).hide().removeAttr("href");
		if($(window).scrollTop()!="0"){
			$(this).fadeIn("slow");
		}
		var scrollDiv=$(this);
		$(window).scroll(function(){
			if($(window).scrollTop()=="0"){
				$(scrollDiv).fadeOut("slow");
			}else{
				$(scrollDiv).fadeIn("slow");
			}
		});
		$(this).click(function(){
			$("html, body").animate({scrollTop:0},"slow");
		});
	};//Ham ScrollTop
	
});

$(function() {
	$("#go_top").scrollToTop();
});

